#pragma once

#include <QByteArray>
#include <QDataStream>
#include <QDateTime>
#include <QString>
#include <memory>
#include "GameData.h"
#include "GameEnums.h"

// 游戏数据包基类
struct GamePacket 
{
    PacketType type;
    quint32 playerId;
    quint32 timestamp;
    
    GamePacket();
    GamePacket(PacketType t, quint32 id);
    virtual ~GamePacket() = default;
    
    virtual QByteArray serialize() const;
    static std::unique_ptr<GamePacket> deserialize(const QByteArray& data);
};

// 游戏状态数据包
struct GameStatusPacket : GamePacket 
{
    PlayerGameData playerData;
    MonsterData monsterData;
    QString message;
    
    GameStatusPacket();
    GameStatusPacket(quint32 id, const PlayerGameData& pData, const MonsterData& mData, const QString& msg = "");
    
    QByteArray serialize() const override;
};

// 攻击数据包
struct AttackPacket : GamePacket 
{
    quint32 damage;
    quint32 targetHealth;
    QString message;
    
    AttackPacket();
    AttackPacket(PacketType type, quint32 id, quint32 dmg, quint32 health, const QString& msg = "");
    
    QByteArray serialize() const override;
};

// 升级数据包
struct LevelUpPacket : GamePacket 
{
    PlayerGameData newPlayerData;
    QString message;
    
    LevelUpPacket();
    LevelUpPacket(quint32 id, const PlayerGameData& data, const QString& msg = "");
    
    QByteArray serialize() const override;
};

// 战斗消息数据包
struct CombatMessagePacket : GamePacket 
{
    QString message;
    
    CombatMessagePacket();
    CombatMessagePacket(quint32 id, const QString& msg);
    
    QByteArray serialize() const override;
}; 